package main

func groupThePeople(groupSizes []int) [][]int {
	m := make(map[int][]int) //key-每个组大小，value-属于该组大小的成员编号的数组
	for i, groupSize := range groupSizes {
		m[groupSize] = append(m[groupSize], i)
	}
	res := make([][]int, 0)
	for groupSize, arr := range m {
		for i := 0; i < len(arr)/groupSize; i++ { //测试用例保证一定能整除
			res = append(res, arr[groupSize*i:groupSize*(i+1)])
		}
	}
	return res
}
